﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace CheckersUI
{
    public delegate void CellClickHandler(UICheckersCell i_UICheckersCell);
    
    public partial class UICheckersCell : Button
    {
        public event CellClickHandler OnButtonClick;

        private bool m_IsClicked = false;
        private char m_CellSymbol;
        private char m_CellColumn;
        private char m_CellRow;

        public UICheckersCell()
        {
            this.InitializeComponent();
            this.m_CellSymbol = ' ';
        }

        public char Column
        {
            get
            {
                return this.m_CellColumn;
            }

            set
            {
                this.m_CellColumn = value;
            }
        }

        public char Row
        {
            get
            {
                return this.m_CellRow;
            }

            set
            {
                this.m_CellRow = value;
            }
        }

        public char Symbol
        {
            get
            {
                return this.m_CellSymbol;
            }

            set
            {
                this.m_CellSymbol = value;
            }
        }

        public bool IsClicked
        {
            get
            {
                return this.m_IsClicked;
            }

            set
            {
                this.m_IsClicked = value;
            }
        }

        private void UICheckersCell_Click(object sender, EventArgs e)
        {
            if (!this.m_IsClicked)
            {
                this.m_IsClicked = true;
                this.BackColor = Color.LightBlue;
            }
            else
            {
                this.m_IsClicked = false;
                this.BackColor = Color.White;
            }

            if (this.OnButtonClick != null)
            {
                this.OnButtonClick.Invoke(sender as UICheckersCell);
            }
        }
    }
}